function bOnClick() {
	$("#dialog").dialog({
		resizable: false
	});
	var resizable = $("#dialog").dialog('option', 'resizable');
	$("#dialog").dialog('option', 'resizable', false);
	var startStation = $("input[name='startStationCode']").val();
	var endStation = $("input[name='endStationCode']").val();
	var startDate = $("input[name='startDate']").val();

	ajaxReq(startStation, endStation, startDate);
}

function aOnClick() {
	var startStation = $("input[name='start1Code']").val();
	var endStation = $("input[name='end1Code']").val();
	var startDate = $("input[name='date1']").val();
	$("#trainContent").html('');
	ajaxReq(startStation, endStation, startDate);
}

function getUrlParam(key) {
	// 获取参数
	var url = window.location.search;
	// 正则筛选地址栏
	var reg = new RegExp("(^|&)" + key + "=([^&]*)(&|$)");
	// 匹配目标参数
	var result = url.substr(1).match(reg);

	// 返回参数值
	return result ? decodeURIComponent(result[2]) : null;
}

function ajaxReq(startStation, endStation, startDate) {
	$.ajax({
		type: 'get',
		url: 'trainServlet',
		data: {
			'startStation': startStation,
			'endStation': endStation,
			'startDate': startDate
		},
		success: function (data) {
			var trainList = JSON.parse(data);
			for (var i = 0; i < trainList.length; i++) {
				var ttHtml = "<tr class='td' onmouseover=this.style.backgroundColor='#ffff66'; onmouseout=this.style.backgroundColor='#d4e3e5'>";
				ttHtml += '<td width="80">' + trainList[i].number + '</td>';
				ttHtml += '<td width="30">' + trainList[i].type + '</td>';
				ttHtml += '<td width="52">' + trainList[i].startStation + '</td>';
				ttHtml += '<td width="82">' + trainList[i].startStationType + '</td>';
				ttHtml += '<td width="52">' + trainList[i].endStation + '</td>';
				ttHtml += '<td width="82">' + trainList[i].endStationType + '</td>';
				ttHtml += '<td width="82">' + trainList[i].startTime + '</td>';
				ttHtml += '<td width="82">' + trainList[i].endTime + '</td>';
				ttHtml += '<td width="82">' + trainList[i].runTime + '</td>';
				var currPrice = trainList[i].trainPrice;
				ttHtml += '<td width="52">' + currPrice.business + '</td>';
				ttHtml += '<td width="52">' + currPrice.special + '</td>';
				ttHtml += '<td width="52">' + currPrice.firstClass + '</td>';
				ttHtml += '<td width="52">' + currPrice.secondClass + '</td>';
				ttHtml += '<td width="52">' + currPrice.highSoftSleep + '</td>';
				ttHtml += '<td width="52">' + currPrice.softSleep + '</td>';
				ttHtml += '<td width="52">' + currPrice.hardSleep + '</td>';
				ttHtml += '<td width="52">' + currPrice.softSeat + '</td>';
				ttHtml += '<td width="52">' + currPrice.hardSeat + '</td>';
				ttHtml += '<td width="52">' + currPrice.standing + '</td>';
				ttHtml += '<td width="37">' + trainList[i].runDistance + '</td>';
				$("#trainContent").append(ttHtml);
			}
		}
	});
}
